options ls=85 nocenter;
libname save '/bbkinghome/sschaner/Angrist Work/Web Papers/Angrist_2002/immig/1900/sasdata/';

/* table1m.sas: for Helen 6-15-00, DESCRIPTIVES FOR MEN

   from FIRSTWOM2: female first stage and RF's: uses data94b

   revised 6-14-00 to use corrected income score imputation

   from firstwom1
   6-4-00 RETYPED

   1910,1920,1940 focus

   firstwom1 reads save.rd1900m6 or save.rd1900m8

   note: rd1900m6 uses mother, father-or-both CODES
         rd1900m8 uses father, mother-or-both CODES
         (use m6 for 40/60 follow-ups)
         data94b uses father, mother-or-both, codes mtongue hebrew

   note: 6-14-00 version of data94b omits hebrew

*/

data fb1;                               ** potential MALE fb spouses; 
 set save.data11b;

 if (female=1 & 18<=age<=33) or (female=0 and 20<=age<=35);

 if (nativity=5) and (91<=year<=94);
        
 older=(age=>36);

 cohort=(1*(year=91))+(2*(year=92))+(3*(year=94));
 cohort=cohort+(older/10);
 
proc sort data=fb1;
 by cohort code;

proc freq;
 tables cohort*year;

proc summary data=fb1;
 weight slwt;
 var female;
 by cohort code;
 output out=fb2 mean=pctfem sumwgt=nimmig;

proc print;
title 'first-stage sex ratios for aged 20-50 in 1910,1920,1940';

data two;                               ** micro FEMALE sample for follow-ups;
 set save.data11b;

 if (91<=year<=94) and (1<=nativity<=5);
 if (female=1 and (18 le age le 33)) or (female=0 and (20 le age le 35));
 if nativity=1 then column='native';
	else if 2 le nativity le 4 then column='2ndgen';
	else if nativity=5 then column='fb';
	
 cohort=(1*(year=91))+(2*(year=92))+(3*(year=94));
 if cohort ne .;
  keep slwt age fb nw_fmp evermar nchild famsize myfamsiz relateg 
	inlf occscore famscore year column female gq incwage fwage1
	marst labforce momrule cohort code occ1950;
	run;
	
proc sort data=two;
 by cohort code;

data men;
 merge two fb2;
 by cohort code;

 if (age ne .);

 women=pctfem*nimmig;
 men=(1-pctfem)*nimmig;
 ratio=men/women;

 lnimmig=log(nimmig);

 label ratio='men/women among fb';

 ** outcomes **;

 married=(1<=marst<=2);
 evermar=(marst<6);
 if evermar=1 then alone=(2<=marst<=4);
 spsepres=(marst=1);

 *inlf=(labforce=2); inlf= (0 le occ1950 le 990);
 anykids=(nchild>0);

 ** relationship outcomes (m8 only) **;

 femhead=(relateg=1);
 mominhh=(1<=momrule<=3);
 
 length fb nw_fmp married evermar inlf 3;
 
 keep slwt age fb nw_fmp married evermar nchild mominhh famsize myfamsiz
	relateg inlf occscore famscore ratio year column female gq incwage fwage1;
	run;
	
data men;
 set men;
 if female=0;
 if slwt gt 0 and relateg ne 13;
 run;
 

proc sort data=men;
 by year column;
 
proc means data=men; 
 weight slwt;
 title 'MEN aged 20-50 in 1910-40, weighted by Slwt';
 var age fb nw_fmp married evermar nchild mominhh famsize myfamsiz
	inlf occscore famscore ratio incwage fwage1;
 by year column;
run;

proc tabulate data=men;
class year column;
weight slwt;
var age nchild ;
table year, column*(age nchild)*stddev; run;